const Article = require("../model/article.modle");

class ArticleServer {
  async createArticleServer(data) {
    const res = await Article.create(data);
    return res;
  }
  async getArticleServer(data) {
    const res = await Article.findAll({});
    return res;
  }
  async updateArticleServer(data) {
    const { id, ...result } = data;
    console.log(id);
    console.log(result);
    const res = await Article.update(result, {
      where: { id },
    });
    console.log(res);
    return res[0] > 0;
  }
  async deleteArticleServer(data) {
    const { id } = data;
    const res = await Article.destroy({ where: { id } });
    return res;
  }
}
module.exports = new ArticleServer();
